<template>
  <div>
    <input type="text" v-if="showInp" ref="inp" />
    <button @click="isShow">点击搜索</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showInp: false,
    };
  },
  methods: {
    isShow() {
      this.isShow = true;
      this.$nextTick(() => {
        this.$refs.inp.focus();
      });
    },
  },
};
</script>

<style>
</style>